<?php namespace App\Services;

use App\Facades\Infra\CleanManager;

class CleanService{
	public function createClean($data){
		CleanManager::createClean($this->formatData($data));
	}

	public function getCleans($conditions){
		return CleanManager::getCleans($this->formatConditions($conditions),true)->orderBy('created_at','desc')->paginate(15);
	}

	public function getClean($conditions){
		return CleanManager::getCleans($this->formatConditions($conditions));
	}

	public function updateClean($data){
		$conditions['id'] = $data['id'];

		CleanManager::updateClean($this->formatConditions($conditions),$data);
	}

	public function deleteClean($conditions){
		CleanManager::deleteClean($conditions);
	}

	private function formatData($data){
		$data['hotel_id'] = \Auth::user()->id;

		return $data;
	}

	private function formatConditions($conditions){
		$conditions['hotel_id'] = \Auth::user()->id;

		return $conditions;
	}
}